package com.wn.date20190802;

import java.util.concurrent.CountDownLatch;

import javax.swing.tree.VariableHeightLayoutCache;

public class Array2
{

	/**
	 * 将一个数组的偶数输入另一个数组
	 */
	public static void main(String[] args)
	{
		int[] arr1 = { 123, 324, 673, 567, 3256, 73, 6, 6, 2, 67, 26, 23,124,54656,7,68783,1 };
		//先建一个长度一样的数组，存偶数
		
		int[] arr2 = new int[arr1.length];
		//记录偶数个数
		int evenCount = 0;
		for (int i = 0; i < arr1.length; i++)
		{
			if (arr1[i] % 2 == 0)
			{
				arr2[evenCount] = arr1[i];
				evenCount++;
			}

		}
		//定义偶数长度的数组，作为最终结果
		int[] arrFinal = new int[evenCount];
		for (int i = 0; i < evenCount; i++)
		{
			arrFinal[i] = arr2[i];
		}
		for (int a : arrFinal)
		{
			System.out.print(a + " ");
		}

	}
}
